package com.example.parallelTemplate.commons.task;

import com.example.parallelTemplate.commons.dto.BaseRspDTO;
import com.example.parallelTemplate.commons.dto.LabelDTO;
import com.example.parallelTemplate.commons.param.LabelParam;
import com.example.parallelTemplate.commons.req.AppInfoReq;
import com.example.parallelTemplate.commons.service.ILabelService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class LabelStrategyTask implements IBaseTask {

    @Resource
    private ILabelService labelService;

    @Override
    public String getTaskType() {
        return "labelDTO";
    }

    @Override
    public BaseRspDTO<Object> execute(AppInfoReq req) {
        LabelParam labelParam = labelService.buildLabelParam(req);
        LabelDTO labelDTO = labelService.queryLabelInfo(labelParam);
        BaseRspDTO<Object> userBaseRspDTO = new BaseRspDTO<Object>();
        userBaseRspDTO.setKey(getTaskType());
        userBaseRspDTO.setData(labelDTO);
        return userBaseRspDTO;
    }
}
